CPE 332
Computer Engineering
Mathematics II
Part III, Chapter 11
Numerical Differentiation and Integration
• Chapter 11 Numerical Differentiation and Integration
– Derivative Approximation
• Forward, Backward, Centered Difference
• High Order Derivative
• High Accuracy Approximation
– Integral Approximation
• Polynomial
– Zero Order
– First Order (Trapezoidal)
– Second Order (Simpson 1/3)
– Third Order (Simpson 3/8)
• More Accurate Method
– Richardson Extrapolation
Slope of Line
m=slope = tan θ
= (y2-y1)/ (x2-x1)
(x2,y2)
(y2-y1)
θ
θ
(x1,y1)
(x2-x1)
• Derivative of f(x) at any point x is the slope of the tangent line at that point (x,f(x))
• Mathematically
y
∆
f ( x + x
∆ ) − f ( x
Derivative of
( ) ≡ lim
=
)
f x
lim
x
∆ →0
x
x
∆
∆ →0
x
∆
• For function y=f(x), derivative of function is written in many forms
dy
' ( ),
',
(read '
dee -
d
y ee - x' or
)
f
x
y
y
dx
Approximation of slope at point x using secant line
• Slope at ‘ x’ ≅ [ f( x+∆ x) - f( x)] / ∆ x = ∆ y / ∆ x As ∆ x approaches 0,
we have ∆y/∆x
approach a true slope
of f at x.
( x+∆ x, f( x+∆ x)) f( x+∆ x) - f( x) ( x, f( x))
=∆ y
∆ x
Derivative(Forward) f ( x + ∆) − f x f '( x) =
( )
lim
∆→0
∆
∆ y
∆
Derivative(Backward) f ( x) − f ( x − ∆
f '( x) =
)
lim
∆→0
∆
∆ y
∆
Derivative(Central) f ( x + ∆) − f ( x − ∆
f '( x) =
)
lim
∆→0
2∆
∆ y
x
∆
x
∆
• ในทางปฎิบัติ เราได ้ Sample ของ Data เป็นจุด การหา
Derivative ก็คือการลบค่าของจุด Data ที่อยู่ติดกันและ
หารด ้วยระยะห่างระหว่างจุด นี่คือวิธีการของ Finite Divided-Difference h h
f(xi+1)
f(xi)
f(xi-1)
xi-1 x
i xi+1
Finite Divided-Difference
Finite Divided-Difference
Finite Divided-Difference
f '''( x ) 3
h
f ( x ) − f ( x ) = 2 f '( x ) h + 2
i
+...
i 1
+
i 1
−
i
!
3
Second Derivative
Second Derivative
High Accuracy Finite
Divided-Difference
High Accuracy Finite
Divided-Difference
Summary
Summary
Summary
• Newton-Cotes Integration Formula
• Zero-Order Approximation
• First-Order Approximation
– Trapezoidal Rule
• Second-Order Approximation
– Simpson 1/3 rule
• Third-Order Approximation
– Simpson 3/8 rule
• Romberg Integration
– Richardson Extrapolation
– Romberg Integration Algorithm
Integral Approximation x0 x1 x2 x3 x4
xn-1 xn
Zero-Order Approximation
x0 x1 x2 x3 x4
xn-1 xn
• a0=f(a)
x0 x1 x2 x3 x4
xn-1 xn
b
b
I =
f ( x) dx ≈ a dx = a [ b − a] = f ( a)[ b − a]
∫
∫ 0
0
a
a
• a0=f((a+b)/2)
x0 x1 x2 x3 x4
xn-1 xn
b
b
a + b
I =
f ( x) dx ≈ a dx = a [ b − a] = f (
)[ b − a]
∫
∫ 0
0
2
a
a
Zero-Order
App
roximation
First-Order Approximation x0 x1 x2 x3 x4
xn-1 xn
First-Order Approximation
First-Order Approximation
First-Order Approximation
Trapezoidal Rule
Trapezoidal Rule
Second-Order Approximation x0 x1 x2 x3 x4
xn-1 xn
Simpson’s 1/3 Rule
Second-Order Approximation
Second-Order Approximation
Second-Order Approximation
3n
Second-Order Approximation
Third-Order Approximation x0 x1 x2 x3 x4
xn-1 xn
Simpson’s 3/8 Rule
Third Degree Approximation
Simson’s 3/8 Rule
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Romberg Integration
Summary
• Download HW
• Next Week
– ส่งการบ ้าน HW 10
– Chapter 11 Solutions of ODE
– HW 11 (Option)